package {package}.{obj.lower}.entity;

import java.io.Serializable;
import java.time.LocalDateTime;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang3.StringUtils;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;

import com.neusoft.hifly.commons.lang.LocalDateUtil;
import com.neusoft.hifly.commons.lang.StringConstants;


/**
 * Title: {project.name}-{project.app}
 * <p>
 * Description: {obj.name}对象
 * <p>
 * Copyright: {project.copyright}
 * <p>
 * Company: {project.company}
 * 
 * @author {project.author}
 * @version {project.version}
 */
@JsonIgnoreProperties(ignoreUnknown = true)
@TableName(value = "{table.name}")
public class {obj}Obj implements Serializable {
	{param}

	// ################### 临时数据 ####################

	// 格式化后的字符串日期
	@TableField(exist = false)
	private String updateTimeStr;
	// 状态
	@TableField(exist = false)
	private String statusStr;

	/**
	 * 得到对象的哈希值
	 * 
	 * @return int 对象的哈希值
	 */
	public int hashCode() {
		return new HashCodeBuilder().append(this.getLogicId()).toHashCode();
	}

	/**
	 * 比较两个对象是否相等
	 * 
	 * @param other
	 *            要比较的对象
	 * @return boolean 相同返回true，否则返回flase
	 */
	public boolean equals(final Object other) {
		if (!(other instanceof {obj}Obj)) {
			return false;
		}
		final {obj}Obj castOther = ({obj}Obj) other;
		return new EqualsBuilder().append(this.getLogicId(), castOther.getLogicId()).isEquals();
	}

	/**
	 * 返回对象的字符串值
	 * 
	 * @return String 表示用户对象的字符串值
	 */
	public String toString() {
		return JSON.toJSONString(this);
	}

	/**
	 * 将DATE类型的时间格式化为字符串类型
	 * 
	 * @return 字符串时间
	 */
	public String getUpdateTimeStr() {
		if (this.updateTime != null) {
			this.updateTimeStr = LocalLocalDateUtil.showTime(this.updateTime);
		}
		return this.updateTimeStr;
	}

	public String getStatusStr() {
		if (StringConstants.YES.equals(this.getStatus())) {
			this.statusStr = "启用";
		} else {
			this.statusStr = "停用";
		}
		return statusStr;
	}

	public String getStatus() {
		if (StringUtils.isEmpty(status)) {
			status = StringConstants.YES;
		}
		return status;
	}

	{getter}

	public void setStatusStr(String statusStr) {
		this.statusStr = statusStr;
	}
	
	public void setUpdateTimeStr(final String updateTimeStr) {
		this.updateTimeStr = updateTimeStr;
	}
	
}
